package cn.domob.android.ads;

import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.content.pm.PackageManager;
import android.database.Cursor;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.os.Handler;
import android.os.Message;
import android.provider.MediaStore.Images.Media;
import android.view.ViewGroup;
import android.widget.RelativeLayout;
import android.widget.RelativeLayout.LayoutParams;
import android.widget.Toast;
import cn.domob.android.a.a;
import cn.domob.android.a.c;
import java.io.File;
import java.util.Hashtable;

public class DomobActivity extends Activity
{
  public static final String ACTIVITY_TYPE = "DomobActivityType";
  public static final String EXPAND_BASE_URL = "ex_base_url";
  public static final String EXPAND_CONTENT = "ex_content";
  public static final String EXPAND_URL = "ex_url";
  public static final String NOTICE_MESSAGE = "msg";
  public static final int TYPE_DOWNLOADER = 2;
  public static final int TYPE_EXPAND = 4;
  public static final int TYPE_INSTALL_RECEIVER = 1;
  public static final int TYPE_NONE = 0;
  public static final int TYPE_NOTICE = 3;
  public static final int TYPE_UPLOAD_PIC = 5;
  private static J a = new J(DomobActivity.class.getSimpleName());
  private static final int b = 2345;
  private static final int c = 2346;
  private static String d = Environment.getExternalStorageDirectory() + "/DomobUploadImgPath/";
  private static String e = "up";
  private static final int g = 0;
  private static final int h = 1;
  private Handler f;
  private Context i = this;
  private String j = "";
  private Uri k;

  private String a(Uri paramUri)
  {
    Cursor localCursor = managedQuery(paramUri, new String[] { "_data" }, null, null, null);
    int l = localCursor.getColumnIndexOrThrow("_data");
    localCursor.moveToFirst();
    return localCursor.getString(l);
  }

  private void d()
  {
    if (getIntent().getExtras() == null)
      return;
    Intent localIntent = getIntent();
    String str1 = localIntent.getStringExtra("appName");
    this.j = localIntent.getStringExtra("appId");
    String str2 = localIntent.getStringExtra("actType");
    if ((str2 == null) || (!str2.equals("typeCancel")))
      return;
    new AlertDialog.Builder(this.i).setTitle("取消").setMessage(str1 + "正在下载是否取消?").setNegativeButton("取消下载", new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface paramDialogInterface, int paramInt)
      {
        a locala = (a)a.a.get(DomobActivity.a(DomobActivity.this));
        if (locala != null)
        {
          locala.b();
          c localc = locala.a();
          if (localc != null)
            localc.b();
        }
        DomobActivity.this.finish();
      }
    }).setPositiveButton("继续下载", new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface paramDialogInterface, int paramInt)
      {
        DomobActivity.this.finish();
      }
    }).show();
  }

  private void e()
  {
    if (getIntent().getExtras() == null)
      return;
    String str = getIntent().getStringExtra("msg");
    new AlertDialog.Builder(this.i).setMessage(str).setNegativeButton("确定", new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface paramDialogInterface, int paramInt)
      {
        DomobActivity.this.finish();
      }
    }).show();
  }

  private void f()
  {
    a.a("Reload expandable part in DomobActivity.");
    H localH;
    String str1;
    if (getIntent().getExtras() != null)
    {
      localH = new H(this.i, null, 0);
      Intent localIntent = getIntent();
      str1 = localIntent.getStringExtra("ex_url");
      String str2 = localIntent.getStringExtra("ex_base_url");
      String str3 = localIntent.getStringExtra("ex_content");
      if ((str3 == null) || (str2 == null))
        break label209;
      a.a(String.format("Reload EX with url=%s and data=%s", new Object[] { str2, str3 }));
      localH.loadDataWithBaseURL(str2, str3, "text/html", "UTF-8", null);
    }
    while (true)
    {
      Dialog localDialog = new Dialog(this.i, 16973840);
      localDialog.setOnDismissListener(new DialogInterface.OnDismissListener(localH)
      {
        public void onDismiss(DialogInterface paramDialogInterface)
        {
          ((ViewGroup)this.a.getParent()).removeAllViews();
          DomobActivity.this.finish();
        }
      });
      RelativeLayout.LayoutParams localLayoutParams1 = new RelativeLayout.LayoutParams(-1, -1);
      RelativeLayout localRelativeLayout = new RelativeLayout(this.i);
      localRelativeLayout.setLayoutParams(localLayoutParams1);
      RelativeLayout.LayoutParams localLayoutParams2 = new RelativeLayout.LayoutParams(-2, -2);
      localLayoutParams2.addRule(13);
      localRelativeLayout.addView(localH, localLayoutParams2);
      localDialog.setContentView(localRelativeLayout);
      localDialog.show();
      return;
      label209: if (str1 == null)
        break;
      a.a(String.format("Reload EX with url=%s", new Object[] { str1 }));
      localH.loadUrl(str1);
    }
    a.e("Failed to load Expandable without URL or BASE URL and CONTENT.");
    finish();
  }

  private void g()
  {
    this.f = new Handler()
    {
      public void handleMessage(Message paramMessage)
      {
        super.handleMessage(paramMessage);
        switch (paramMessage.what)
        {
        default:
          return;
        case 1:
          Toast.makeText(DomobActivity.b(DomobActivity.this), "照片上传成功", 1).show();
          DomobActivity.c(DomobActivity.this);
          return;
        case 0:
        }
        Toast.makeText(DomobActivity.b(DomobActivity.this), "照片上传失败", 1).show();
      }
    };
    new AlertDialog.Builder(this.i).setTitle("选择方式").setMessage("选择上传图片的方式").setNegativeButton("从已有相册中选择", new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface paramDialogInterface, int paramInt)
      {
        DomobActivity.e(DomobActivity.this);
      }
    }).setPositiveButton("照相获得图片", new DialogInterface.OnClickListener()
    {
      public void onClick(DialogInterface paramDialogInterface, int paramInt)
      {
        DomobActivity.d(DomobActivity.this);
      }
    }).show();
  }

  private boolean h()
  {
    PackageManager localPackageManager = this.i.getPackageManager();
    Intent localIntent = new Intent("android.media.action.IMAGE_CAPTURE");
    File localFile = new File(d);
    if (!localFile.exists())
      localFile.mkdir();
    localIntent.putExtra("output", Uri.fromFile(new File(d + e)));
    if (localPackageManager.resolveActivity(localIntent, 65536) != null)
    {
      startActivityForResult(localIntent, 2345);
      return true;
    }
    return false;
  }

  private boolean i()
  {
    PackageManager localPackageManager = this.i.getPackageManager();
    Intent localIntent = new Intent("android.intent.action.GET_CONTENT");
    localIntent.setType("image/*");
    if (localPackageManager.resolveActivity(localIntent, 65536) != null)
    {
      startActivityForResult(localIntent, 2346);
      return true;
    }
    return false;
  }

  private void j()
  {
    File localFile1 = new File(d + e);
    if (localFile1.exists())
      localFile1.delete();
    File localFile2 = new File(d);
    if (!localFile2.exists())
      return;
    localFile2.delete();
  }

  public void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
  {
    switch (paramInt1)
    {
    default:
      return;
    case 2345:
      a.b("update the pic taken");
      new Thread()
      {
        public void run()
        {
          String str = DomobActivity.a() + DomobActivity.b();
          Bitmap localBitmap = BitmapFactory.decodeFile(str);
          long l = new File(str).length();
          DomobActivity.c().a("The size of pic taken =" + l);
          o.a(localBitmap, l);
          DomobActivity.f(DomobActivity.this).sendEmptyMessage(0);
        }
      }
      .start();
      return;
    case 2346:
    }
    a.b("update the pic selected");
    if (paramIntent == null)
    {
      a.b("album select url is null");
      return;
    }
    this.k = paramIntent.getData();
    new Thread()
    {
      public void run()
      {
        try
        {
          Bitmap localBitmap = MediaStore.Images.Media.getBitmap(DomobActivity.b(DomobActivity.this).getContentResolver(), DomobActivity.g(DomobActivity.this));
          long l = new File(DomobActivity.a(DomobActivity.this, DomobActivity.g(DomobActivity.this))).length();
          DomobActivity.c().a("selected pic size =" + l);
          if (o.a(localBitmap, l))
          {
            DomobActivity.f(DomobActivity.this).sendEmptyMessage(1);
            return;
          }
          DomobActivity.f(DomobActivity.this).sendEmptyMessage(0);
          return;
        }
        catch (Exception localException)
        {
          DomobActivity.c().a(localException);
        }
      }
    }
    .start();
  }

  public void onCreate(Bundle paramBundle)
  {
    switch (getIntent().getIntExtra("DomobActivityType", 0))
    {
    default:
      finish();
      return;
    case 2:
      super.onCreate(paramBundle);
      d();
      return;
    case 1:
      setTheme(16973835);
      super.onCreate(paramBundle);
      return;
    case 3:
      super.onCreate(paramBundle);
      e();
      return;
    case 4:
      super.onCreate(paramBundle);
      f();
      return;
    case 5:
    }
    super.onCreate(paramBundle);
    g();
  }
}

/* Location:           C:\Users\god\Desktop\liunianjishiben_V1.1_mumayi_3745b_dex2jar.jar
 * Qualified Name:     cn.domob.android.ads.DomobActivity
 * JD-Core Version:    0.5.4
 */